<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #03a9f4;position:fixed;" id="header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            选择缺陷内容
        </div>
    </header>
    <script id="opTemp" type="text/x-dot-template">

        {{~ it:value:index}}
        <li class="aui-list-item" onclick="setQualchkitem('{{= it[index].sysid }}','{{= it[index].code }}','{{= it[index].name }}');">   
            <div class="aui-list-item-inner">
                <div>{{= it[index].code }}:{{= it[index].name }}</div>
            </div>
        </li>
        {{~}}

    </script>
    <div class="aui-content aui-margin-b-15" style="margin-top:55px;">
        <div class="aui-searchbar" id="search" style="position: sticky;top: 55px;z-index: 10;">
            <div class="aui-searchbar-input aui-border-radius">
                <i class="aui-iconfont aui-icon-search"></i>
                <div class="aui-searchbar-input">
                    <form action="javascript:doSearch();">
                        <input type="search" placeholder="请输入缺陷编码/缺陷名称" id="names">
                    </form>
                </div>
            </div>
            <div class="aui-btn aui-btn-primary" style="margin-right: 0.5rem;background-color: #03a9f4"
                onclick="doSearch()">搜索</div>
        </div>
        <ul id="tbodyHtml">

        </ul>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>

<script type="text/javascript">
    var code
    var arrSaveId = []
    var arrSaveName = []
    // 创建一个空数组来存储选中复选框的值

    apiready = function () {
        code = api.pageParam.code;
        doSearch();
    };

    //查询物料列表
    function doSearch() {
        var name = $("#names").val();
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/usmSelectQualchkitemFx";
        var data = {
            values: {
                name: name,
                un: un,
                code: code,
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 30,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var list = eval(myobj.list);
                    var html = "";
                    for (var i = 0; i < list.length; i++) {
                        html += "<li class='sortable ui-selectee ui-sortable'>";
                        html += "<ul class='aui-list aui-media-list ui-selectee'>";
                        html += "<li class='aui-list-item  ui-selectee'style='background-color: #F0FFFF;'>";
                        html += "<div class='aui-media-list-item-inner ui-selectee' >";
                        html += "<div class='aui-list-item-inner ui-selectee' >";
                        html += "<div class='aui-list-item-text ui-selectee'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title' style='width:40%'>缺陷编码</div>";
                        html += "<div class='aui-list-item-inner ui-selectee' >" + list[i].code + "</div>";
                        html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title' style='width:40%'>缺陷名称</div>";
                        html += "<div class='aui-list-item-inner ui-selectee'>" + list[i].name + "</div>";
                        html += "</div>";
                        // html += "<div class='aui-list-item-text ui-selectee' style='height: 30px;'>";
                        // html += "<div class='aui-list-item-label ui-selectee list-tr-title' style='width:60%'>返修工艺路线编码</div>";
                        // if( list[i].ext14 !=null){
                        //     html += "<div class='aui-list-item-inner ui-selectee' style='margin-left:2%'>" + list[i].ext14 + "</div>";
                        // }else{
                        //     html += "<div class='aui-list-item-inner ui-selectee'>" + '' + "</div>";
                        // }

                        // html += "</div>";
                        html += "<div class='aui-list-item-text ui-selectee'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title' style='width:75%'>返修工艺路线名称</div>";
                        if (list[i].ext15 != null) {
                            html += "<div class='aui-list-item-inner ui-selectee' style='margin-left:2%'>" + list[i].ext15 + "</div>";
                        } else {
                            html += "<div class='aui-list-item-inner ui-selectee'>" + '' + "</div>";
                        }
                        html += "<div style='background-color: #FFE4E1;' class='aui-list-item-right aui-btn ui-selectee'  " +
                            "onclick='setQualchkitem(\"" + list[i].sysid + "\",\"" + list[i].code + "\",\"" + list[i].name + "\",\"" + list[i].ext14 + "\",\"" + list[i].ext15 + "\",\"" + list[i].ext13 + "\");'>带回</div>";

                        html += "</div>";
                        var height = 30
                        if (list[i].opcode != null) {
                            var s = Math.ceil(list[i].opcode.length / 18);
                            console.log(s)
                            height += s * 10;
                        }
                        html += "<div class='aui-list-item-text ui-selectee' style='height: " + height + "px;'>";
                        html += "<div class='aui-list-item-label ui-selectee list-tr-title' style='width:40%'>返修工序</div>";
                        if (list[i].opcode != null) {
                            html += "<div class='aui-list-item-inner ui-selectee' style='margin-left:2%'>" + list[i].opcode + "</div>";
                        } else {
                            html += "<div class='aui-list-item-inner ui-selectee'>" + '' + "</div>";
                        }
                        html += "</div>";
                        html += "</div>";
                        html += "</div>";
                        html += "</li>";
                        html += "</ul>";
                        html += "</li>";
                    }
                    $api.html($api.byId("tbodyHtml"), html);
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                    //清空表格数据
                    $api.html($api.byId("tbodyHtml"), "");
                }
            }
        });
    }

    //选则返回函数
    function setQualchkitem(sysid, code, name, routeCode, routeName, routeId) {
        api.closeWin();
        var nameR = api.pageParam.name;
        api.execScript({
            name: nameR,
            script: 'setQualchkitem("' + sysid + '","' + code + '","' + name + '","' + routeCode + '","' + routeName + '","' + routeId + '")'
        });

    }
    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>